"""
    @Author  ：思念 
    @File    ：12.线程池批量上传任务的方式.py
    @Date    ：2025/3/6 14:41 
"""
import time
import random
from concurrent.futures import ThreadPoolExecutor

url = 'https://movie.douban.com/top250?start={}&filter='

def get_movie_info(url):
    print("爬取地址URL为:", url)
    time.sleep(random.randint(1,2))
    return "返回值URL:" + url



pool = ThreadPoolExecutor()
url_list = [url.format(i*25) for i in range(10)]
print(url_list)

# map会返回一个迭代器对象，第二个参数为可迭代对象
futures = pool.map(get_movie_info,url_list)
for future in futures:
    print(future)

